import 'dart:convert';

extension ListExtension on List {
  List<T> deepCopy<T>( T Function(Map<String, dynamic>) fromJson) {
    if(this.isEmpty){
      return [];
    }
    String jsonString = json.encode(this.map((item) => (item as dynamic).toJson()).toList());
    List<dynamic> jsonList = json.decode(jsonString);
    List<T> copiedList = jsonList.map((item) => fromJson(item)).toList();
    return copiedList;
  }

}
